import React from "react";
/**
 * 父传子
 */
class Hello extends React.Component{
    constructor(props){
        //不传则是undefined
        super(props)
        console.log('构造方法',this.props);
    }

    render(){
        let {stname,age,hobby,fun,tag}=this.props;//解构
        return(
            <div>
                <h1>组件传参</h1>
                <p>字符串{this.props.stname}</p>
                <p>字符串2:{stname}年龄:{age+2}</p>
                <p>数组:{hobby}</p>
                <button onClick={fun}>点我触发传来的函数</button><br/>
                标签:{tag}
            </div>
        )
    }
}

export default Hello